home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 12658 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: malgudi.oar.net!usenet
  2. From: Kevin Finley <kfinley@carsinfo.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: More questions on generic/templated classes
  5. Date: 20 Mar 1996 21:30:09 GMT
  6. Organization: OARnet
  7. Message-ID: <4iptd1$cqh@ns.oar.net>
  8. NNTP-Posting-Host: probe.carsinfo.com
  9.  
  10. Hi all,
  11.   First, in reference to Josh in article 167766, yes you can
  12. use typedefs with templates.  My experience indicates they are
  13. simply a convenience (and a mighty nice on I might add:)
  14.   Second, from my prototyping, it seems that most compilers
  15. compile templates the first time they need to instantiate an
  16. object of that type.  Some compilers seem to compile template
  17. code the first time they run into a declaration - such as
  18. "typedef blah<x> blah_x;"  Also, from my prototyping, your
  19. worry about multiple compilations within one source file seems
  20. unfounded - templates are compiled the first time necessary
  21. in a source file and that is reused.
  22.   However, now we come to my question.  g++ (I haven't checked
  23. my other compilers yet and thought I would look to net wisdom)
  24. seems to compile this code for each and every source file and
  25. will not allow extern as extern and typedef are both type
  26. modifiers.  Does anyone know a way to make the linker look
  27. for the code to match a template in another object.
  28.   Note that I was surprised to see g++ generate the same
  29. mangled name three times for the same template and functions
  30. and have all three successfully link into my executable.
  31.   Also not that the results seem to be the same when I declare
  32. a class which extends the template - such as
  33. "class x : public blah<int>"
  34.  
  35. TIA
  36. Kevin Finley
  37. CARS Information Systems Corp (CIS)
  38.